﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Group3.MediaTool.Core.Reactive
{
    /// <summary>
    /// @Version: 1.0
    /// @Author: Pascal Senjic
    /// @Comment:
    ///     Handles the ative observers.
    /// </summary>
    public class EntityUnsubscriber : IDisposable
    {
        private IEnumerable<IObserver<Group3.MediaTool.Interface.IObjectRelationModel>> observers;
        private IObserver<Group3.MediaTool.Interface.IObjectRelationModel> observer;

        public EntityUnsubscriber(IEnumerable<IObserver<Group3.MediaTool.Interface.IObjectRelationModel>> col, 
            IObserver<Group3.MediaTool.Interface.IObjectRelationModel> observer)
        {
            this.observer = observer;
            this.observers = col;
        }
        public void Dispose()
        {
            if (this.observer != null && this.observers.Contains(this.observer))
            {
                ((List<IObserver<Group3.MediaTool.Interface.IObjectRelationModel>>)this.observers).Remove(observer);
            }
        }
    }
}
